package com.yylending.las.main.message;

import com.yyfax.infrastructure.eventbus.EventAgent;
import com.yyfax.infrastructure.mvp.Model;
import com.yyfax.infrastructure.network.NetworkHelper;
import com.yyfax.infrastructure.network.entity.BaseResultEntity;
import com.yyfax.infrastructure.network.entity.EmptyEntity;
import com.yylending.las.Global;

import retrofit2.http.Body;
import retrofit2.http.Header;
import retrofit2.http.POST;
import rx.Observable;

/**
 * 消息红点展示
 * Created by ying_he on 2017/8/3.<br>
 * Copyright  2017 www.yylending.com. All Rights Reserved.<br><br>
 */

public class MsgStatusModel extends Model{
    @Override
    public Observable getObservable(Object params, int functionalCode) {
        Service service = (Service) NetworkHelper.createService(Service.class);
        return service.getMsgStatus(Global.LOGIN_TOKEN, (EmptyEntity) params);
    }

    @Override
    public void onNext(Object entity) {
        MsgStatusResult msgStatusResult= (MsgStatusResult) entity;
        EventAgent.post(msgStatusResult);
    }

    private interface Service {
        @POST("server/message/getCount")
        Observable<MsgStatusResult> getMsgStatus(@Header("token") String token, @Body EmptyEntity params);
    }

    static class MsgStatusResult extends BaseResultEntity<MsgStatus>{

    }

    static class MsgStatus{
        public String count = "";
    }
}
